package com.ia.aistream.controller.operating;//package com.ia.aistream.controller.operating;

import java.util.List;

import com.ia.aistream.common.annotation.Log;
import com.ia.aistream.model.operating.entity.DocContentParagraph;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ia.aistream.common.enums.BusinessType;

import com.ia.aistream.service.operating.IDocContentParagraphService;
import com.ia.aistream.common.core.controller.BaseController;
import com.ia.aistream.common.core.domain.AjaxResult;
import com.ia.aistream.common.utils.poi.ExcelUtil;
import com.ia.aistream.common.core.page.TableDataInfo;

/**
 * content_paragraphController
 *
 * @author aistream
 * @date 2021-01-20
 */
@Controller
@RequestMapping("/docContentPargraph/paragraph")
public class DocContentParagraphController extends BaseController
{
    private String prefix = "operating/paragraph";

    @Autowired
    private IDocContentParagraphService docContentParagraphService;

    @RequiresPermissions("operating:paragraph:view")
    @GetMapping()
    public String paragraph()
    {
        return prefix + "/paragraph";
    }

    /**
     * 查询content_paragraph列表
     */
    @RequiresPermissions("operating:paragraph:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DocContentParagraph docContentParagraph)
    {
        startPage();
        List<DocContentParagraph> list = docContentParagraphService.selectDocContentParagraphList(docContentParagraph);
        return getDataTable(list);
    }

    /**
     * 导出content_paragraph列表
     */
    @RequiresPermissions("operating:paragraph:export")
    @Log(title = "content_paragraph", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DocContentParagraph docContentParagraph)
    {
        List<DocContentParagraph> list = docContentParagraphService.selectDocContentParagraphList(docContentParagraph);
        ExcelUtil<DocContentParagraph> util = new ExcelUtil<DocContentParagraph>(DocContentParagraph.class);
        return util.exportExcel(list, "paragraph");
    }

    /**
     * 新增content_paragraph
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存content_paragraph
     */
    @RequiresPermissions("operating:paragraph:add")
    @Log(title = "content_paragraph", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DocContentParagraph docContentParagraph)
    {
        return toAjax(docContentParagraphService.insertDocContentParagraph(docContentParagraph));
    }

//    /**
//     * 批量增加
//     * @param list
//     * @return
//     */
//    @RequiresPermissions("operating:paragraph:add")
//    @Log(title = "content_paragraph", businessType = BusinessType.INSERT)
//    @PostMapping("/adds")
//    @ResponseBody
//    public AjaxResult addServes(List<DocContentParagraph> list)
//    {
//        return toAjax(docContentParagraphService.insertDocContentParagraphList(list));
//    }

    /**
     * 修改content_paragraph
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DocContentParagraph docContentParagraph = docContentParagraphService.selectDocContentParagraphById(id);
        mmap.put("docContentParagraph", docContentParagraph);
        return prefix + "/edit";
    }

    /**
     * 修改保存content_paragraph
     */
    @RequiresPermissions("operating:paragraph:edit")
    @Log(title = "content_paragraph", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DocContentParagraph docContentParagraph)
    {
        return toAjax(docContentParagraphService.updateDocContentParagraph(docContentParagraph));
    }



    /**
     * 删除content_paragraph
     */
    @RequiresPermissions("operating:paragraph:remove")
    @Log(title = "content_paragraph", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(docContentParagraphService.deleteDocContentParagraphByIds(ids));
    }
}
